extends Component
var _player:CharacterBody2D
@onready var state_chart: StateChart = $StateChart
func _ready() -> void:
	_player=host
	set_player_skin(_player.skin)
	Global.set_player_skin.connect(set_player_skin)
	state_chart.send_event("look_around")
func _enable()->void:
	set_physics_process(true)
	if not Global.player_animation_event.is_connected(state_chart.send_event):Global.player_animation_event.connect(state_chart.send_event)
func _disable()->void:
	set_physics_process(false)
	if Global.player_animation_event.is_connected(state_chart.send_event):Global.player_animation_event.disconnect(state_chart.send_event)
func _physics_process(delta: float) -> void:
	pass

func set_player_skin(skin:CompressedTexture2D)->void:
	if skin:
		%Display.box_skin=skin
		%Display.box_color=Color.WHITE

func _on_blink_timer_timeout() -> void:
	var index:int=randi_range(0,5)
	if index!=0:state_chart.send_event("blink")
	else:state_chart.send_event("look_around")
